{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "88bb77ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 5, 2, 3, 7, 6],\n",
       "       [2, 5, 8, 1, 7, 6]])"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "tang_array = np.array([[1,5,2,3,7,6],[2,5,8,1,7,6]])\n",
    "tang_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "307c121b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3, 5, 6, 7],\n",
       "       [1, 2, 5, 6, 7, 8]])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sort(tang_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "68289988",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 5, 2, 1, 7, 6],\n",
       "       [2, 5, 8, 3, 7, 6]])"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sort(tang_array,axis=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a150db80",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 2, 3, 1, 5, 4],\n",
       "       [3, 0, 1, 5, 4, 2]], dtype=int64)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.argsort(tang_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "ca47848b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 0.        ,  1.11111111,  2.22222222,  3.33333333,  4.44444444,\n",
       "        5.55555556,  6.66666667,  7.77777778,  8.88888889, 10.        ])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang_array = np.linspace(0,10,10)\n",
    "tang_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a78a8cbb",
   "metadata": {},
   "outputs": [],
   "source": [
    "values = np.array([2,5,6,5,9,5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e032dc61",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([2, 5, 6, 5, 9, 5], dtype=int64)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.searchsorted(tang_array,values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "5d9adce6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 0, 6],\n",
       "       [1, 7, 0],\n",
       "       [2, 3, 1],\n",
       "       [2, 4, 0]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang_array = np.array([[1,0,6],[1,7,0],[2,3,1],[2,4,0]])\n",
    "tang_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "561c6d54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3, 1, 2, 0], dtype=int64)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "index = np.lexsort([-1*tang_array[:,0],tang_array[:,2]])\n",
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e759b3b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[2, 4, 0],\n",
       "       [1, 7, 0],\n",
       "       [2, 3, 1],\n",
       "       [1, 0, 6]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tang_array = tang_array[index]\n",
    "tang_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "49555b3e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
